home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group96a.txt / 000124_icon-group-sender _Sat Jun 8 15:50:25 1996.msg < prev    next >
Internet Message Format  |  1996-09-05  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 10 Jun 1996 07:59:41 MST
  2. To: icon-group@cs.arizona.edu
  3. Date: 8 Jun 1996 15:50:25 -0700
  4. From: dave@cs.arizona.edu (Dave Schaumann)
  5. Message-Id: <4pd03h$g3o@lectura.CS.Arizona.EDU>
  6. Organization: University of Arizona CS Department, Tucson AZ
  7. Sender: icon-group-request@cs.arizona.edu
  8. References: <199606071540.LAA18004@morgoth>, <4pa3hq$lpc@labrador.cs.purdue.edu>
  9. Subject: Re: m3 should have SWAP(a,b)
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11. Status: O
  12.  
  13. In article <4pa3hq$lpc@labrador.cs.purdue.edu>,
  14. Norman Ramsey <nr@cs.purdue.edu> wrote:
  15. >In article <199606071540.LAA18004@morgoth>,
  16. >Warren Smith <wds@research.nj.nec.com> wrote:
  17. > >R.W.Floyd pointed out the desirability of
  18. > >   a <--> b
  19. > >and
  20. > >  (a,b,c) <-- (f,g,h)     
  21. > >swap and simultaneous assignment - primitives in his Turing
  22. > >award lecture about 20 years ago, but so far as I know, the SWAP
  23. > >recommendation has not been provided in a common language
  24. > >since then. 
  25. >
  26. >Icon has swap, notated :=:
  27.  
  28. As you say.  For my part, the only time I've found 'swap' to be a useful
  29. operation is when I am writing sort algorithm (or sort-related algorithms,
  30. like heap manipulation).  Since (in my experience, anyway) this is not a
  31. frequent occurrance, it doesn't seem like the best idea in the world to
  32. include 'swap' as part of any language's basic repetoir of operations.
  33.  
  34. Perhaps others have found a more extensive use for swapping?
  35.  
  36. >I've wished for multiple assignment many times but have never seen it
  37. >outside of the LISP family, where it masquerades as `let'.
  38.  
  39. What about Icon?
  40.  
  41.     record Foo(first, second, third)
  42.  
  43.  
  44.     fghFoo := Foo(f, g, h)
  45.     abcFoo := copy(fghFoo)
  46.  
  47.  
  48. Some observations:
  49.     1. No, in the most literal sense, this is not 'mulitple
  50.        assignment', but
  51.     2. It accomplishes the same thing, and
  52.     3. If three variables are closely related enough to
  53.        group in a multiple assignment, don't they belong in
  54.        a Record anyway?
  55.     4. The example extends to any language that supports
  56.        record assignment by copying.
  57.  
  58. -Dave
  59.